﻿using System.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DependencyInjectionExample
{
	class Program
	{
		static void Main(string[] args)
		{
			IDependentClass dependency = GetCorrectDependency();

			MainClass mainClass = new MainClass();
			mainClass.DependentClass = dependency;
			mainClass.DoSomething();

			Console.ReadKey();
		}

		static IDependentClass GetCorrectDependency()
		{
			string classToCreate = ConfigurationManager.AppSettings["class1"];
			Type type = Type.GetType(classToCreate);
			IDependentClass dependency = (IDependentClass)Activator.CreateInstance(type);
			return dependency;
		}
	}
}
